#region Usings

using System;
using System.Collections.Generic;

#endregion

namespace KanbanBoard.Tests.Utils {
    public static class BasicParseExtensions {
        public static Dictionary<string, List<string>> BasicParse(this string expression) {
            var lines = expression.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
            var columnPadding = lines[0].Padding();

            var result = new Dictionary<string, List<string>>();

            string lastColumn = null;
            foreach (var line in lines) {
                if (line.Padding() == columnPadding) {
                    lastColumn = line.Trim();
                    result[lastColumn] = new List<string>();
                }
                else {
                    result[lastColumn].Add(line.Trim());
                }
            }
            return result;
        }
    }

    internal static class StringExtensions {
        internal static int Padding(this string str) {
            return str.Length - str.TrimStart().Length;
        }
    }
}